package com.tengju.support.domain.model.message;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;

@AllArgsConstructor
public enum MessageType {

    BULLETIN(1,"公告"),
    PRIVATE_MESSAGE(2,"客服私信"),
    SYSTEM_INFORMATION(3,"系统消息"),
    APP_PUSH(4,"app推送"),
    SMS(5,"短信"),
    ;

    private Integer val;
    private String desc;

    @JsonValue
    public Integer getVal() {
        return val;
    }

    public String getDesc() {
        return desc;
    }

    @JsonCreator
    public static MessageType fromVal(Integer val) {
        for (MessageType type : values()) {
            if (type.val.equals(val)) {
                return type;
            }
        }
        return null;
    }
}
